package lianxi1;

public class commodity {
    public commodity() {}
    private String name;
    private double price;
    private int quantity=0;


    public commodity(String name, double price, int quantity) {
        this.name = name;
        this.price = price;
        this.quantity = quantity;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return price
     */
    public double getPrice() {
        return price;
    }

    /**
     * 设置
     * @param price
     */
    public void setPrice(double price) {
        this.price = price;
    }

    /**
     * 获取
     * @return quantity
     */
    public int getQuantity() {
        return quantity;
    }

    /**
     * 设置
     * @param quantity
     */
    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

   public void show() {
        System.out.println("商品名称：" + name + " 商品价格：" + price + " 商品数量：" + quantity);
    }

    public void add(commodity c) {
        this.name = c.getName();
        this.price = c.getPrice();
        this.quantity += c.getQuantity();
    }

}
